﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using ECCIT;
using ECCIT.Utilities;
using OgilvyOne.UKNow.Model;
using OgilvyOne.UKNow.BLL;

public partial class GateService_LoginGate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/xml";
        Response.ContentEncoding = Encoding.UTF8;

        string output = string.Empty;
        try
        {
            ResultInfo valRes = ValidateArguments();

            if (valRes.Result)
            {
                string loginType = Request.Params["type"];
                string op = Request.Params["op"];
                string accessToken = Request.Params["access_token"];

                if (loginType.ToLower().Equals("qq") && op.ToLower().Equals("get_openid"))
                {
                    ResultInfo reqResult = QQLoginBLL.GetOpenID(accessToken);
                    if (reqResult.Result)
                        output = JsonUtil.Serialize(reqResult.ReturnObject);
                    else
                        output = JsonUtil.Serialize(reqResult);
                }
                else
                    output = "{\"access_token\":\"" + accessToken + "\"}";
            }
        }
        catch (Exception ex)
        {
            output = "<files value=\"false\"></files>";
        }

        Response.Write(output);
    }

    private ResultInfo ValidateArguments()
    {
        ResultInfo result = new ResultInfo(true);
        return result;
    }
}